import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'
import Empty from '../views/layout/empty'
import AsyncComponent from '../components/AsyncComponent.vue'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes example mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: title               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
    {
        path: '/redirect',
        component: Layout,
        hidden: true,
        children: [
            {
                path: '/redirect/:path*',
                component: () => import('@/components/redirect/index')
            }
        ]
    },
    { path: '/login', component: () => import('@/views/login/index'), hidden: true },
    { path: '/404', component: () => import('@/views/404'), hidden: true },
    { path: '/layout', component: () => import('@/views/combination/Layout'), hidden: true },
    { path: '/preview', component: () => import('@/views/combination/preview'), hidden: true },
    { path: '/formMaking', component: () => import('@/views/formMaking/index'), hidden: true },
    { path: '/formMaking/pc', component: () => import('@/views/formMaking/PcIndex'), hidden: true },
    { path: '/formMaking/setmoban', component: () => import('@/views/formMaking/SetMoBan'), hidden: true },
    { path: '/formMaking/phone', component: () => import('@/views/formMaking/PhoneIndex'), hidden: true },
    { path: '/formMakingPreview', component: () => import('@/views/formMaking/preview'), hidden: true },
    {
        path: '/iframe',
        component: Layout,
        redirect: '/iframe', // you can set roles in root nav
        hidden: true,
        children: [{
            path: ':routerPath',
            component: () => import('@/views/iframe/index'),
            name: 'iframe',
            meta: {
                title: 'iframe',
                icon: 'people'
            }
        }]
    },
    {
        path: '',
        component: Layout,
        redirect: 'dashboard',
        hidden: true,
        children: [{
            path: 'dashboard',
            component: () => import('@/views/dashboard/index'),
            name: 'Dashboard',
            meta: { title: 'Dashboard', icon: 'dashboard', noCache: true, affix: true }
        }]
    },
    {
        path: 'example',
        component: Layout,
        redirect: '/example/menu1',
        name: '例子',
        meta: {
            title: '例子',
            icon: 'icon-search'
        },
        'children': [
            {
                path: 'menu1',
                component: Empty,
                name: '战略远景规划',
                meta: {
                    title: '战略远景规划',
                    icon: 'icon-search'
                },
                'children': [
                    {
                        path: '/i18n-demo',
                        component: () => import('@/views/example/i18n-demo'),
                        name: 'I18n',
                        meta: {
                            title: 'i18n',
                            icon: 'icon-search',
                            noCache: false
                        }
                    },
                    {
                        path: '/nine-card',
                        component: () => import('@/views/example/dragNineCard'),
                        name: 'dragNineCard',
                        meta: {
                            title: 'dragNineCard',
                            icon: 'icon-search',
                            noCache: false
                        }
                    },
                    {
                        path: '/table',
                        component: () => import('@/views/example/table'),
                        name: 'table685',
                        meta: {
                            title: '表格',
                            noCache: false
                        }
                    },
                    {
                        path: '/iframedemo',
                        component: () => import('@/views/example/iframe'),
                        name: 'iframedemo',
                        meta: {
                            title: 'iframedemo',
                            noCache: false
                        }
                    },

                    {
                        path: '/table2',
                        component: () => import('@/views/example/table2'),
                        name: 'treetable',
                        meta: {
                            title: '树主从',
                            noCache: false
                        }
                    },
                    // {
                    //     path: '/table3',
                    //     component: () => import('@/views/form/per_360template_rela/per_360template_rel_tree'),
                    //     name: 'per_360template_rel_tree',
                    //     meta: {
                    //         title: '树主从2',
                    //         noCache: false
                    //     }
                    // },
                    {
                        path: '/table4',
                        component: () => import('@/views/example/table4'),
                        name: 'table4',
                        meta: {
                            title: '树夺标',
                            noCache: false
                        }
                    },
                    {
                        path: '/table5',
                        component: () => import('@/views/example/table5'),
                        name: 'pre_cadreReg_list',
                        meta: {
                            title: '人员容器',
                            noCache: false
                        }
                    },
                    // per_360template_rel_tree
                    {
                        path: '/tinymce',
                        component: () => import('@/views/example/tinymce'),
                        name: 'TinymceDemo',
                        meta: { title: 'tinymce' }
                    },
                    // {
                    //     path: '/layout1',
                    //     component: () => import('@/views/example/layout/layout2'),
                    //     name: 'layout1',
                    //     meta: {
                    //         title: '布局',
                    //         noCache: false
                    //     }
                    // },
                    {
                        path: '/layout2',
                        component: () => import('@/views/example/layout/layout2'),
                        name: 'layout2',
                        meta: {
                            title: '布局',
                            noCache: false
                        }
                    },
                    {
                        path: '/departSelect',
                        component: () => import('@/views/example/departSelect'),
                        name: 'departSelect',
                        meta: {
                            title: '部门选择器',
                            noCache: false
                        }
                    },
                    // {
                    //     path: '/layout3',
                    //     component: () => import('@/views/example/layout/layout3'),
                    //     name: 'layout3',
                    //     meta: {
                    //         title: '布局',
                    //         noCache: false
                    //     }
                    // },
                    // {
                    //     path: '/layout4',
                    //     component: () => import('@/views/form/org_manage/org_compan/ORG_EMPJOBMM/ORG_EMPJOBMM_VUE'),
                    //     name: 'layout4',
                    //     meta: {
                    //         title: '布局测试',
                    //         noCache: false
                    //     }
                    // },
                    {
                        path: '/chart1',
                        component: () => import('@/views/example/charts/index'),
                        name: 'chart1',
                        meta: {
                            title: 'echarts',
                            noCache: false
                        }
                    },
                    {
                        path: '/card',
                        component: () => import('@/views/example/card/index'),
                        name: '名片',
                        meta: {
                            title: '名片',
                            noCache: false
                        }
                    },
                    {
                        path: '/card2',
                        component: () => import('@/views/example/card/emp_hetongdqi_vue'),
                        name: '测试图标',
                        meta: {
                            title: '测试图标',
                            noCache: false
                        }
                    },
                    {
                        path: '/fmCard',
                        component: () => import('@/views/example/card/fm-card'),
                        name: '生成名片',
                        meta: {
                            title: '生成名片',
                            noCache: false
                        }
                    },
                    {
                        path: '/fmCard2',
                        component: () => import('@/views/example/emp_hetongdqi_vue'),
                        name: '测试连接',
                        meta: {
                            title: '测试连接',
                            noCache: false
                        }
                    },
                    {
                        path: '/kanban',
                        component: () => import('@/views/example/Kanban/index'),
                        name: '可拖拽名片',
                        meta: {
                            title: '可拖拽名片',
                            noCache: false
                        }
                    },
                    {
                        path: '/orgTree',
                        component: () => import('@/views/example/orgTree/index'),
                        name: '组织树',
                        meta: {
                            title: '组织树',
                            noCache: false
                        }
                    },
                    {
                        path: '/organize/index',
                        component: () => import('@/views/example/dragOrg/index'),
                        // component: () => resolve('@/views/example/performance/score',resolve),
                        name: 'organize',
                        meta: {
                            title: '组织机构图'
                            // noCache: false
                        }
                    },
                    // customTreeTable
                    // {
                    //     path: '/customTreeTable',
                    //     component: () => import('@/views/form/001/Radartest'),
                    //     name: '树列表',
                    //     meta: {
                    //         title: '树列表',
                    //         noCache: false
                    //     }
                    // },
                    // {
                    //     path: '/dept_info_list',
                    //     component: () => import('@/views/form/dept_info_list'),
                    //     name: 'dept_info_list',
                    //     meta: {
                    //         title: 'dept_info_list',
                    //         noCache: false
                    //     }
                    // },
                    {
                        path: '/table3',
                        component: () => import('@/views/example/table3'),
                        name: 'handsontable',
                        meta: {
                            title: 'handsontable',
                            noCache: false
                        }
                    },
                    {
                        path: '/cardform',
                        component: () => import('@/views/example/form'),
                        name: 'form',
                        meta: {
                            title: 'form',
                            noCache: false
                        }
                    },
                    {
                        path: '/gantt',
                        component: () => import('@/views/example/gantt'),
                        name: '甘特图',
                        meta: {
                            title: '甘特图',
                            noCache: false
                        }
                    },
                    {
                        path: '/question',
                        component: () => import('@/views/example/questionForm'),
                        name: '问卷',
                        meta: {
                            title: '问卷'
                        }
                    }
                    // {
                    //     path: '/orgWork',
                    //     component: () => import('@/views/form/org_manage/ORG_DESKTOP/ORG_ORGWORK_VUE'),
                    //     name: 'orgWork',
                    //     meta: {
                    //         title: 'orgWork'
                    //     }
                    // }
                ]
            }
        ]
    },
    {
        path: '/asyncForm', // 动态匹配
        component: Layout, // 已知组件
        hidden: true,
        name: 'asyncForm',
        children: [{
            path: '/asyncForm/:id',
            component: AsyncComponent,
            name: 'asyncForm',
            meta: { title: 'async' }
        }]
    },
    { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
    // mode: 'history', //后端支持可开
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRouterMap
})
